﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace CUIT.GraduationProject.ToolBoxSystem.PropertyLib
{
    public partial class PropertyLibForm : UserControl
    {
        enum States { Compressed = 1, Compressing, Extended, Extending };

        private Button ScrollButton1 = new Button();
        private Button ScrollButton2 = new Button();
        private int ButtonHeight = 22;//18;
        private int XOffset = 22;
        private int YOffset = 20;
        private int RightMargin = 5;
        private int Acceleration = 2;
        private bool Bounce = true;
        private int ScrollButtonX;
        private int ButtonWidth;
        private int ListWidth;
        private int Delay = 2000;
        private System.Windows.Forms.Splitter splitter1;
        private bool DoneMove = true;
        private System.Windows.Forms.ToolTip toolTip;
        private bool Retreat = true;
        private bool RetreatCommand = false;
        private bool ExpandCommand = false;
        private string Separator = ".";
        private int state = (int)States.Extended;
        private System.Windows.Forms.MenuItem Menu_Dock_Left;
        private System.Windows.Forms.MenuItem Menu_Dock_Right;
        private System.Windows.Forms.MenuItem Menu_Autohide;
        private System.Windows.Forms.MenuItem Menu_Hide;
        private System.Windows.Forms.MenuItem Menu_About;
        private ContextMenu CMenu = null;

        public delegate void OnToolBoxClick(int TabIndex, int ItemIndex);
        public delegate void OnToolBoxTabChanged(int TabIndex);
        public delegate void OnToolBoxStateChanged(int State);

        private OnToolBoxClick OnTBClick = null;
        private OnToolBoxTabChanged OnTBTabChanged = null;
        private System.Windows.Forms.Panel panel;
        private System.Windows.Forms.PictureBox Picture;
        private System.Windows.Forms.ContextMenu contextMenu;
        private System.Windows.Forms.ImageList imageList1;
        private System.Windows.Forms.Timer timer1;
        private OnToolBoxStateChanged OnTBStateChanged = null;

        private ArrayList arrMoveList = new ArrayList();
        private ArrayList arrSizeList = new ArrayList();
        private int delay = 0;
        private int sbdelay = 0;

        /// <summary>
        ///  初始化
        /// </summary>
        public PropertyLibForm()
        {
            InitializeComponent();
        }

        /// <summary>
        ///  加载
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void PropertyLib_Load(object sender, EventArgs e)
        {
            Control ctr = new Control();
            ctr.Name = "";
            ctr.Size = new Size(10, 10);
            ctr.Location = new Point(1137, 0);
            ctr.Visible = true;
            ctr.BackColor = "red";
            propertyGrid_Pro.SelectedObject = ctr;
        }

        /// <summary>
        ///  设置大小
        /// </summary>
        /// <param name="size">大小</param>
        public void SetSize(Size size)
        {
            this.Size = size;
        }

        private void timerRoll_Tick(object sender, EventArgs e)
        {
            Point pt = this.PointToClient(MousePosition);
            Rectangle rect = new Rectangle(pt, new Size(1, 1));
            bool MouseOver = (ClientRectangle.IntersectsWith(rect) && !panel.ClientRectangle.IntersectsWith(rect));

            if (MouseOver) ExpandCommand = true;

            if (arrMoveList.Count > 0)
            {
                DoneMove = false;
            }
            else
            {
                DoneMove = true;
            }
            for (int i = 0; i < arrMoveList.Count; i++)
            {
                MoveObject mo = ((MoveObject)arrMoveList[i]);
                mo.Increment_State();
                if (mo.faze == mo.endfaze)
                {
                    arrMoveList.RemoveAt(i);
                    i--;
                }
            }
            for (int i = 0; i < arrSizeList.Count; i++)
            {
                SizeObject so = ((SizeObject)arrSizeList[i]);
                so.Increment_State();
                if (so.faze == so.endfaze)
                {
                    arrSizeList.RemoveAt(i);
                    i--;
                }
            }
        }
    }
}
